home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / platforms and tools / mpw / remove vms version numbers / removevmsversionnumbers
Encoding:
Text File  |  2000-09-28  |  1.9 KB  |  55 lines

  1. #
  2. ## MPW Script for removing VMS style version numbers from file
  3. ## names. By Godfrey DiGiorgi, Apple Computer, 16MAR92
  4. #
  5. # Description:
  6. #    Given a folder of files with ';<number>' extensions, create
  7. #    and execute a command file to rename them, eliminating 
  8. #    the extensions.
  9. #
  10. # Limitation:
  11. #    If the stripped version of a filename will conflict with another
  12. #    stripped filename, the file will not be renamed. This will happen
  13. #    in version-extension number order, ie:
  14. #        given: this.foo;1 this.foo;2 this.foo;3
  15. #        execute this script
  16. #        result: this.foo this.foo;2 this.foo;3
  17. #
  18. # Usage: 
  19. # 0-Put this file into your "{Tools}" folder in the MPW Shell folder
  20. # 1-Set your working folder to the folder of files
  21. #     that needs to have the ';<num>' ending stripped with the 
  22. #     MPW 'Directory' command or menu.
  23. # 2-Execute this file from the Worksheet
  24. #
  25. # Comments:
  26. # I leave the file 'namechange' in your MPW Shell directory so that 
  27. # you can open it and see exactly what file was renamed what according
  28. # to the MPW 'Rename' command.
  29. #
  30. # Enjoy!  -gdg
  31. #
  32. ## set shell variable - don't exit script on errors
  33. set exit 0 
  34. ## get rid of old namechange command file
  35. del "{MPW}namechange" ≥≥ "{Worksheet}" 
  36. ## assemble command file
  37. for F in `files -f -s -o`  ## list all files, no folders, no headers, full path
  38.     echo -n "rename -c " >> "{MPW}namechange"
  39.     quote -n "{F}" >> "{MPW}namechange" ## filenames need quoting
  40.     echo -n " " >> "{MPW}namechange"
  41.     quote "{F}" >> "{MPW}namechange"
  42. end
  43. ## edit command file ##
  44. open -t "{MPW}namechange" ## open file as target
  45. find • "{MPW}namechange"  ## go to top of file
  46. ## replace all occurences of ';<num>' where <num> is a single digit
  47. ## (you will need to add another '?' character if these are 2-digit)
  48. replace -c ∞ /";"?"∂'∂n"/ "∂'∂n" "{MPW}namechange"
  49. ## close command file with save
  50. close -y "{MPW}namechange"
  51. ## execute commands 
  52. "{MPW}namechange"
  53. ## reset shell variable
  54. set exit 1
  55.